package com.hanamaki.oop.demo13;

import java.util.Scanner;

public class Demo01 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入名字");
        String next = scanner.next();
        System.out.println(next);

        // 会报出 堆栈溢出错误
//        new Demo01().a();

//         算数异常
        int a = 0;   // ctrl + alt +t
        try {
            a = 1 / 0;
        } catch (ArrayIndexOutOfBoundsException e) {
             // a = 1/1;
            System.out.println("分母不能为0+++++》ArrayIndexOutOfBoundsException");
        } catch (ArithmeticException e) {
            System.out.println(e.getMessage());

            System.out.println("分母不能为0+++++》ArithmeticException");
        }finally {
            // 释放资源 善后处理
//            scanner.close();
        }
        System.out.println(a);

        int b = 1;
        System.out.println(b);


    }


    public void a() {
        b();
    }

    public void b() {
        a();
    }
}
